import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 路由表
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue')
  },
  {
    path: '/editUser',
    name: 'editUser',
    component: () => import('@/views/user/components/editUser.vue')
  },
  {
    path: '/',
    // name: 'layout', // 如果父路由有默认子路由，那它的 name 没有意义
    component: () => import('@/views/layout'),
    children: [
      {
        path: '', // 默认子路由，只能有1个
        name: 'home',
        component: () => import('@/views/home/home.vue')
      },
      // 问答页面
      {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/qa')
      },

      // 视频页面
      {
        path: '/video',
        name: 'video',
        component: () => import('@/views/video')
      },
      // 个人中心页面
      {
        path: '/user',
        name: 'user',
        component: () => import('@/views/user/user.vue')
      }
    ]
  }, 
  // 页面错误界面
  {
    path: '/error',
    name: '404',
    component: () => import('@/components/error/404.vue')
  },
  // 文章详情页
  {
    path: '/article/:id',
    name: 'articleInfo',
    component: () => import('@/components/article/article-info.vue')
  },
  //搜索页面
  {
    path: '/search', // 默认子路由，只能有1个
    name: 'search',
    component: () => import('@/views/home/search/search.vue')
  }
]



const router = new VueRouter({
  routes
})





export default router
